function[rlon,rlat]= real2arr(m2lon,m2lat)
%This function was written to convert occam rotated coordinates to real
%world cordinate system.. Basically conversion of the javascript found at
%occam site.. Duude after the lengthy scripting, it was found that the
%coordinates are aslo supplied by occam group!%F$%^&k
%Anyway If you are looking at webpages computation tables and wondering how to do copy the
% back ground script -> save the webpage (complete).. Look for javasript files in the associated folder
% Convert the javascript to matlab sript -? -manoj8aug6
      pi=3.1415926535897932;

      twopi=6.2831853071795865;
      dg2rad=3.1415926535897932/180.0;
       rad2dg=180.0/3.1415926535897932;
% //
% //     Specify the Euler angles, converting from degrees.
% //     This version has Beta=90.0, Gamma=0.0 built in.
      alpha=232.0*dg2rad ;
% //
% //     Derived parameters for the transformation.
% //

     
      ca = cos( alpha );
      sa = sin( alpha );
% //
% //     Copy & rescale input arguments.
% //
      phi2a = m2lon;
      plam2a = m2lat;
      chi2 = dg2rad*phi2a ;
      phi2 = dg2rad*plam2a ;

      cphi2 = cos(phi2);
      sphi2 = sin(phi2);
      schi2g = sin(chi2);
% //
% //     Solve for transformed coordinates.
% //
      phi1 = asin( -1.0*cphi2*cos(chi2) ) ;
      cchi1 = -sa*schi2g*cphi2 + ca*sphi2 ;
      schi1 =  ca*schi2g*cphi2 + sa*sphi2;
% //     If CHI1 is indeterminate (at the poles?), set it to 0.0.
% //     No need to divide SCHI1, CCHI1 by cos(PHI1), as
% //     this is always .GE. 0.0, so won't change result of ATAN2.

      if schi1 == 0.0 & cchi1 == 0.0,
        chi1 = 0.0;
      else,
        chi1 = atan2( schi1,cchi1 ) ;
      end;
% //       change range from (-pi,pi] to [0.0,2*pi)
        if ( chi1 < 0.0 ), chi1 = chi1 + twopi ;end;
      
% //
% //     Write & rescale to output arguments.
% //

        phi1a = rad2dg*chi1;
        if ( phi1a > 359.9999 ), phi1a = 0.0 ;end;
        plam1a = rad2dg*phi1;
        if (abs(phi1a) < 0.000001 ), phi1a = 0.0;end;
        if (abs(plam1a) < 0.000001 ), plam1a = 0.0;end;
	rlon = phi1a;
	rlat = plam1a;
